@export_end(Example.Translator)

function translateGreeting($language){ switch ($language){ case "spanish":return "Hola"; case "german": return "Hallo"; case "english": return "Hello"; case "french": return "Bonjour"; default: return null; } }

@export_end(Example.TranslatorTester)

class TranslatorTester extends \Taeluf\Tester{

//every function that starts with `test` will be run as a test
public function testTranslateSpanish(){
    $actual = translateGreeting('spanish');
    $target = "Hola";
    echo "Target:{$target}\nActual:{$actual}";
    if ($target==$actual)return true;
}
public function prepare(){
    //this code runs BEFORE any of your test code
}
//You can declare other functions that DON'T start with `test` if you need helper functions.

} //TranslatorTester::runAll() // just print the results //TranslatorTester::run(['testTranslateSpanish']) // run every test method given in that array // (new TranslatorTester())->run(); //runs all this way, or pass an array of methods to only run those tests TranslatorTester::runAllToFile(FILE.'.html',$alsoPrint=true); TranslatorTester::xdotoolRefreshFirefox(); // If you have xdotool installed, this will switch to Firefox & refresh focused webpage.

@export_end(Example.TranslatorOutput)

TranslateSpanish: success
Target:Hola Actual:Hola

@export(Extra.RefreshBrowserTab)

Call Taeluf\Tester::xdotoolRefreshFirefox($switchBackToCurrWindow = false) to refresh your browser tab. If you're writing you're using runAllToFile($file), this could come in handy.

@export_end(Example.ModifyOutput)

public function showResult($details){ $successStatement = $details->result ? 'success' : 'fail'; if ($details->error!=null)$successStatement = 'error'; echo "

\n ".$details->method.": ".$successStatement." \n"; echo "
\n"; $detailsOutput = htmlentities($details->output); $detailsLines = explode("\n",$detailsOutput);

        $detailsLines = array_map(function($value){return '        '.$value;},$detailsLines);
        echo implode("\n",$detailsLines);
        // var_dump($detailsLines);
    echo "\n    </div>";
    if ($details->error!=null){
        echo "\n    <br>\n";
        echo "    <div style='color:red;padding-left:4ch;white-space:pre;'>\n";
            $errorOutput = $details->error;
            $errorLines = explode("\n",$errorOutput);
            $errorLines = array_map(function($value){return '        '.$value;},$errorLines);
            echo implode("\n",$errorLines);
        echo "\n    </div>";
    }
echo "\n</details>\n";

}